using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeShieldSiphon:Upgrade {

	float stacksCollected;

	protected override void SubscribeEvents() {
		base.SubscribeEvents();
		MobEventHelper.damaged.SubscribeSingleDamagerWeapon(weaponWeapon,Mob_Damaged);
	}
	public override void UnsubscribeEvents() {
		base.UnsubscribeEvents();
		MobEventHelper.damaged.UnsubscribeSingleDamagerWeapon(weaponWeapon,Mob_Damaged);
	}

	public override void OnDequip() {
		base.OnDequip();
		weapon.owner.buffs[typeof(BuffDamageShield)].stacks-=stacksCollected;
		stacksCollected=0;
	}

	void Mob_Damaged(object _sender,DamageEventArgs e) {
		if(e.stat.amount<0) return;
		if(stacksCollected>2) return;
		stacksCollected+=e.stat.amount*0.005f;
		weapon.owner.buffs[typeof(BuffDamageShield)].stacks+=e.stat.amount*0.005f;
	}

	public override void Update(object sender,WeaponEventArgs e) {
		base.Update(sender,e);
		stacksCollected-=Time.deltaTime*0.2f;
		weapon.owner.buffs[typeof(BuffDamageShield)].stacks-=Time.deltaTime*0.2f;
	}

}
